// 关键字查找函数
function search(){
    var search = document.getElementsByClassName("search");
    // 点击事件，点击搜索时获取关键字并发送请求
    search[1].onclick = function () {
        let key = search[0].value;
        if(!key){
            return;
        }
        ajax({
            type: "get",
            url: "http://www.rushmc.top/api/dynamicState/search/",
            data: {
                key: key
            },
            success: function (response) {
                if (response.code == 200) {
                    setSession("searchresult",response.data);
                    document.location='../'+"搜索动态/index6.html";
                }else{
                    search[1].disabled=true;
                    search[1].innerHTML="搜索失败！";
                    setTimeout(() => {
                        search[1].disabled=false;
                        search[1].innerHTML="搜索";
                    }, 1000);
                }
            }
        })
        
    }
}